﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NewRen.Models.ViewModel
{
    public class vReply
    {
        public int ID { get; set; }

        public int TopicID { get; set; }

        public string TopicTitle { get; set; }

        public string Content { get; set; }

        public DateTime Time { get; set; }

        public int UserID { get; set; }

        public User User { get; set; }


        /// <summary>
        /// 父评论 
        /// </summary>
        public int? FatherID { get; set; }

        public List<Reply> Children { set; get; }

        public vReply() { }
        public vReply(Reply model)
        {
            DB db = new DB();
            this.Content = model.Content;
            this.ID = model.ID;
            this.Time = model.Time;
            this.TopicID = model.TopicID;
            this.User = model.User;
            this.UserID = model.UserID;
            this.TopicTitle = model.Topic.Title;
            this.FatherID = model.FatherID;
            this.Children = db.Replies.Where(r => r.FatherID == model.ID).OrderBy(r => r.Time).ToList();
        }
    }
}